package cn.hnucm.serchhbservice.controller;


import cn.hnucm.serchhbservice.entity.TbHbBasis;
import cn.hnucm.serchhbservice.entity.TbHbImage;
import cn.hnucm.serchhbservice.entity.TbHbRelation;
import cn.hnucm.serchhbservice.service.TbHbRelationService;
import cn.hnucm.serchhbservice.utils.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 皇榜接受关系 前端控制器
 * </p>
 *
 * @author zjl
 * @since 2021-12-09
 */
@Api(tags = "tb_Hb_Relation类")
@RestController
@RequestMapping("/serchhbservice/tbHbRelation")
public class TbHbRelationController {

    @Autowired
    private TbHbRelationService tbHbRelationService;

    /**
     * 路径： /serchhbservice/tbHbRelation/getHbRelation/1
     * 描述: 根据hbId查询tb_hb_relation表
     *
     * @param hbId 皇榜id
     * @return List<TbHbRelation>
     */

    @GetMapping("/getHbRelation/{hbId}")
    public List<TbHbRelation> getHbBasisById(@PathVariable("hbId") int hbId) {
        QueryWrapper<TbHbRelation> tbHbRelationQueryWrapper = new QueryWrapper<>();
        tbHbRelationQueryWrapper.eq("hbId", hbId);
        return tbHbRelationService.list(tbHbRelationQueryWrapper);
    }

    /**
     * 路径： /serchhbservice/tbHbRelation/addHbRelation
     * 描述: 向tb_hb_relation表添加HbRelation
     *
     * @param tbHbRelation 皇榜接收者关系
     * @return boolean
     */

    @PostMapping("/addHbRelation")
    public boolean addHbRelation(@RequestBody TbHbRelation tbHbRelation) {
        return tbHbRelationService.save(tbHbRelation);
    }

    /**
     * 路径： /serchhbservice/tbHbRelation/updateHbRelation
     * 描述: 根据hbId更新tb_hb_relation表的数据
     *
     * @param tbHbRelation 皇榜接收者关系
     * @return boolean
     */

    @PostMapping("/updateHbRelation")
    public boolean updateHbRelation(@RequestBody TbHbRelation tbHbRelation) {
        return tbHbRelationService.updateById(tbHbRelation);
    }

    /**
     * 路径： /serchhbservice/tbHbRelation/deleteHbRelation
     * 描述: 根据hbId删除tb_hb_relation表的数据
     *
     * @param tbHbRelation 皇榜接收者关系
     * @return boolean
     */

    @PostMapping("/deleteHbRelation")
    public boolean deleteHbRelation(@RequestBody TbHbRelation tbHbRelation) {
        return tbHbRelationService.removeById(tbHbRelation.getHbId());
    }
}

